uniform float progress;
attribute vec3 toPosition;
attribute float speed;
attribute float scale;
attribute vec3 color;
attribute vec3 toColor;
varying vec3 vColor;
varying vec2 vUv;

void main() {

    vec3 dis = toPosition - position;
    vec3 disColor = toColor - color;

    float percent = progress / speed;
    vUv = uv;
    vec3 pos;
    if(percent <= 1.) {
        pos = position + dis * percent;
        vColor = color + disColor * percent;
    } else {
        vColor = toColor;
        pos = toPosition;
    }
    // vColor.x = uv.x;
    // vColor.y = uv.y;

    // if(uv.x < 0.) {
    //     vColor.r = 1.0;
    //     vColor.g = 1.0;
    //     vColor.b = 1.0;
    // }

    vec4 viewPosition = modelViewMatrix * vec4(pos, 1.0);
    gl_Position = projectionMatrix * viewPosition;
    gl_PointSize = scale;
    gl_PointSize *= 200. / -(modelViewMatrix * vec4(pos, 1.0)).z;
}